/*
 *  POJ3295: Tautology
 */

/*-------- Includes --------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>

using namespace std;

/*-------- Function prototypes --------*/
bool decode(int v, char c);

/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    char exp[128];

    while (scanf("%s\n", exp) != EOF) {
        int v;
        int n = strlen(exp);

        // reach the end
        if (*exp == '0') break;

        vector<bool> stack;

        for (v = 0; v < 32; v++) {
            char *p = exp + n;
            bool a, b;

            stack.clear();

            while (p-- > exp) {
                if (*p > 0x60) {        // read an operand
                    stack.push_back(decode(v, *p));
                } else         {        // read an operator
                    if (*p == 'N') {    // unary operator
                        a = stack.back(); stack.pop_back();
                        stack.push_back(!a);
                    } else         {    // binary operator
                        b = stack.back(); stack.pop_back();
                        a = stack.back(); stack.pop_back();

                        switch (*p) {
                            case 'K': stack.push_back(a && b); break;
                            case 'A': stack.push_back(a || b); break;
                            case 'C': stack.push_back(!a || b); break;
                            case 'E': stack.push_back(a == b); break;
                            default : break;
                        }
                    }
                }
            }

            if (!stack.back()) break;
        }

        if (v < 32) printf("not\n");
        else        printf("tautology\n");
    }

    return 0;
}

/*-------- Functions --------*/
bool decode(int v, char c)
{
    switch (c) {
        case 'p': return v & (1 << 0);
        case 'q': return v & (1 << 1);
        case 'r': return v & (1 << 2);
        case 's': return v & (1 << 3);
        case 't': return v & (1 << 4);
        default : return false;
    }
}
